<template>
  <div id="app">
    <el-dialog
      title="版本更新信息"
      :visible="dialogVisible && flag"
      :before-close="handleClose"
      width="80%"
    >
      <VersionInfo :has-add-version="false"/>
    </el-dialog>
    <router-view v-if="isRouterAlive"/>
  </div>
</template>

<script>
  import { mapState } from 'vuex'

  export default {
    name: 'App',
    provide() {
      return {
        reload: this.reload
      }
    },

    data() {
      return {
        isRouterAlive: true,
        dialogVisible: true
      }
    },
    computed: {
      ...mapState ({
        flag: state => {
          return state.app.updateInfo.flag
        }
      })
    },
    methods: {
      reload() {
        this.isRouterAlive = false
        this.$nextTick (function() {
          this.isRouterAlive = true
        })
      },
      handleClose() {
        this.dialogVisible = false
      }
    }
  }
</script>
<style lang="scss" scoped>
#app{
  width: 100%;
}
  /deep/ .el-dialog__body {
    max-height: 500px;
    overflow: auto;
  }
</style>
